package com.example.leetdemo.finash;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1200 {

    public static List<List<Integer>> minimumAbsDifference(int[] arr) {
        Arrays.sort(arr);
        List<List<Integer>> result = new ArrayList<>();
        int value = Integer.MAX_VALUE;
        for (int i = 1; i < arr.length; i++) {
            List<Integer> list = new ArrayList<>();
            if (arr[i] - arr[i - 1] < value) {
                value = arr[i] - arr[i - 1];
                result.clear();
                list.add(arr[i - 1]);
                list.add(arr[i]);
            } else if (arr[i] - arr[i - 1] == value){
                list.add(arr[i - 1]);
                list.add(arr[i]);
            } else {
                continue;
            }
            result.add(list);
        }
        return result;
    }

    public static void main(String[] args) {
        List<List<Integer>> list = minimumAbsDifference(new int[] {4,2,1,3});
        System.err.println();
    }
}
